# 多无人机找金币
# 25个无人机 25个格子 
# 还有个思路，32个无人机平均分散在32*32的地图中，全部用右手定则绕圈，应该比这个效率高
def drone():
	n=0
	trigger=[]
	while True:
		n=n+1
		if get_entity_type() == Entities.Treasure:
			use_item(Items.Weird_Substance, length * 2**(num_unlocked(Unlocks.Mazes) - 1))
			trigger.insert(0,n)
		if get_entity_type() == Entities.Treasure and not (len(trigger) <= 4):
			if trigger[0] == trigger[1] + 1 and trigger[0] == trigger[2] + 2:
				harvest()
		#if num_items(Items.Gold) >= 100000000:
		#	break


length = 5
n=0
clear()
set_world_size(length)
if length ** 2 <= max_drones():
	num = length ** 2 - 1
for i in range(num):
	spawn_drone(drone)
	if get_pos_x() == length - 1:	
		move(North)
	move(East)

while True:
	plant(Entities.Bush)
	use_item(Items.Weird_Substance, length * 2**(num_unlocked(Unlocks.Mazes) - 1))
	n=n+1
	if n < 299:
		if get_entity_type() == Entities.Treasure:
			use_item(Items.Weird_Substance, length * 2**(num_unlocked(Unlocks.Mazes) - 1))
	else:
		if get_entity_type() == Entities.Treasure:
			harvest()
			n=0